<?php
/**
	Formul�rio para cadastro de um programa.
*/

if(!isset($_SESSION))
{
   session_start();
}

if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}

$ano = new Ano();
$anosCadastrados = $ano->CarregarAnos();

SAEO::ValidarAcesso( array( 0, 2 ) )

?>
<html>
	<head>
		<title>SAEO - Cadastro de Ação Orçamentária</title>
		<link rel='stylesheet' type='text/css' href='templates/estilos.css'>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type='text/javascript' src='templates/programa.js'></script>
        <script type='text/javascript' src='templates/hintbox.js'></script>
        <script type='text/javascript' src='templates/js.js'></script>
        <script type='text/javascript' src='templates/ajax.js'></script>
        <script type='text/javascript' src='templates/validacoes.js'></script>
	</head>
	<body class='body' onload="document.cadastrar_programa.codResumido.focus(); CarregarNomeProgramas( document.cadastrar_programa.anoId.value ); ">
		<form name='cadastrar_programa' action='EnviarDadosPrograma.php?operacao=1' method='post' onsubmit='return ValidarCadastroPrograma();'>
		<table width='779' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
			<tr>
				<td colspan='2'><?php include "Topo.php"; ?></td>
			</tr>
			<tr>
				<td>
					<div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>CADASTRO DE AÇÃO ORÇAMENTÁRIA</div>
				</td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tr>
                <td>
                	<table class='tabela' width='650' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
						<tr>
							<td>&nbsp;</td>
						</tr>
						<tr>
                               <td class='textoTabelas' width='30%'>&nbsp;Ano do Programa:</td>
                               <td class='textoTabelas'>
                                   <select name='anoId' id='anoId' class='inputTexto'  onchange='CarregarNomeProgramas( this.value );' >
                                           <option value='0'>Selecione o Ano</option>
	                               			<?php
    		                           			$anoAtual = $ano->getAnoAtual(); 
					                            // Percorre o array anosCadastrados e cria options para cada posiï¿½ï¿½o.
			        		                    for ($i = 0; $i < count( $anosCadastrados ); $i++){
			                	            		$status = $anoAtual == $anosCadastrados[$i]->ano ? "selected" : "";
			                    	        		echo "<option value='".$anosCadastrados[$i]->id."' $status>".$anosCadastrados[$i]->ano."</option>";
			                        		    }
											?>
                                   </select>
								<a href='#' class='hintanchor' onMouseover='showhint("Escolha o ano do programa a ser vinculado.", this, event, "220px");'>[?]</a>
                               </td>
                           </tr>
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>
						<tr>
                               <td class='textoTabelas'>&nbsp;Programa: </td>
                               <td class='textoTabelas'>
                               <select name='programas' id='listaProgramas' class='inputTexto'>
                                       <option id='programa' value='0'>Primeiro selecione primeiro o Ano</option>
                               </select>
									<a href='#' class='hintanchor' onMouseover='showhint("Escolha o programa a ser vinculado.", this, event, "220px");'>[?]</a>
                               </td>
                        </tr>
						
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>
						<tr>
							<td class='textoTabelas'>&nbsp;C&oacute;digo Resumido:</td>
							<td>
								<input type='text' name='codResumido' id="codResumido" size='15' maxlength='6' class='inputNumeros' onKeyPress='return formataCampos(this,"??????", event);'>
								<a href='#' class='hintanchor' onMouseover='showhint("C&oacute;digo resumido da ação.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>						
						<tr>
							<td class='textoTabelas'>&nbsp;C&oacute;digo Completo:</td>
							<td>
								<input type='text' name='codCompleto' size='25' class='inputNumeros' maxlength="21" onKeyPress="return formataCampos(this,'!!.!!!.!!!!.!!!!.!!!!', event);"/>
								<a href='#' class='hintanchor' onMouseover='showhint("C&oacute;digo completo da ação.", this, event, "220px");'>[?]</a>
							</td>
						</tr>
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>						
						<tr>
							<td class='textoTabelas'>&nbsp;Nome:</td>
							<td>
								<input type='text' name='nomePrograma' size='49' maxlength='200' class='inputTexto'>
								<a href='#' class='hintanchor' onMouseover='showhint("Nome da ação.", this, event, "220px");'>[?]</a>
							</td>
						</tr>						
						<tr>
							<td colspan='2'>&nbsp;</td>
						</tr>
						<tr>
							<td colspan='2' height='46'>
								<div style='position:relative;left:540px'>
									<input type='image' style='width:100px;height:30px;' onclick='EnviarInformacoes();' src='templates/btavancar.JPG'/>
								</div>
							</td>
						</tr>
                     </table>
                </td>
			</tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tfoot>
	           	<tr>
					<td colspan='2'>&nbsp;</td>
	            </tr>
				<tr>
                   	<?php include 'rodapeCreditos.php'; ?>
                   </tr>
            </tfoot>
		</table>
     	</form>
	</body>
</html>